<template>
    <div class="top-category">
        <div class="container m-top-20">
            <!-- 面包屑 -->
            <div class="bread-container">
                <el-breadcrumb separator=">">
                    <el-breadcrumb-item :to="{ path: '/portal' }">首页</el-breadcrumb-item>
                    <el-breadcrumb-item>{{ this.$route.params.value }}</el-breadcrumb-item>
                </el-breadcrumb>
            </div>

                          <h3>{{this.$route.params.value}}相关中药</h3>
            <!-- 分类商品数据 -->
            <div class="ref-goods" >
                <div class="body">
                    <GoodsItem v-for="good in goodInfo" :good="good" :key="good.id" />
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import GoodsItem from '@/views/Home/components/GoodsItem'
import { mapState } from 'vuex'
export default {
    name:'Search',
    components:{
        GoodsItem,
    },
    created() {
        this.getSearchGoodsData();
    },
    methods:{
        getSearchGoodsData(){
            this.$store.dispatch('detail/getSearchGoodsData',this.$route.params.value);
        }
    },
    computed:{
        ...mapState('detail',['goodInfo']),
    },
    watch:{
        $route(){
            this.getSearchGoodsData()
        }
    }
}
</script>

<style scoped lang="scss">
.top-category {
    h3 {
        font-size: 28px;
        color: #666;
        font-weight: normal;
        text-align: center;
        line-height: 100px;
    }

    .sub-list {
        margin-top: 20px;
        background-color: #FCFAF7;

        ul {
        display: flex;
        padding: 0 32px;
        flex-wrap: wrap;

        li {
            width: 168px;
            height: 160px;


            a {
            text-align: center;
            display: block;
            font-size: 16px;

            img {
                width: 100px;
                height: 100px;
            }

            p {
                line-height: 40px;
            }

            &:hover {
                color: $xtxColor;
            }
            }
        }
        }
    }

    .ref-goods {
        background-color: #FCFAF7;
        margin-top: 20px;
        position: relative;

        .head {
        .xtx-more {
            position: absolute;
            top: 20px;
            right: 20px;
        }

        .tag {
            text-align: center;
            color: #999;
            font-size: 20px;
            position: relative;
            top: -20px;
        }
        }

        .body {
        //display: flex;
        justify-content: space-around;
        //padding: 0 40px 30px;
        }
    }

    .bread-container {
        padding: 25px 0;
    }
}

.home-banner {
    width: 1240px;
    height: 500px;
    margin: 0 auto;

    img {
        width: 100%;
        height: 500px;
    }
}
</style>
